<?php

use yii\db\Migration;

class m000000_000021_create_article_comment extends Migration
{
    public function up()
    {
        $this->createTable('{{%article_comment}}', [
            'id'=>$this->primaryKey(), // PK
            'uid'=>$this->integer(), // 用户编号
            'aid'=>$this->integer(), // 资讯编号
            'cid'=>$this->integer(), // 评论编号
            'content'=>$this->text(), // 评论内容
            'time'=>$this->integer(), // 评论时间
        ]);
        $this->createIndex('fk_article_comment_user1_idx', '{{%article_comment}}', ['uid']);
        try {
            $this->addForeignKey('fk_article_comment_user1', '{{%article_comment}}', ['uid'], '{{%user}}', ['id']);
        } catch (Exception $e) {
        }
        $this->createIndex('fk_article_comment_article1_idx', '{{%article_comment}}', ['aid']);
        try {
            $this->addForeignKey('fk_article_comment_article1', '{{%article_comment}}', ['aid'], '{{%article}}', ['id']);
        } catch (Exception $e) {
        }
        $this->createIndex('fk_article_comment_article_comment1_idx', '{{%article_comment}}', ['cid']);
        try {
            $this->addForeignKey('fk_article_comment_article_comment1', '{{%article_comment}}', ['cid'], '{{%article_comment}}', ['id']);
        } catch (Exception $e) {
        }
    }

    public function down()
    {
        $this->dropTable('{{%article_comment}}');
    }
}
